﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Resto.CostControl.Core.Domain.Model;
using Resto.CostControl.Core.Cache;

namespace Resto.CostControl.Core.Facade.MaterialModule.DataTransferObject
{
    /// <summary>
    /// 原材料加工项
    /// </summary>
    [Serializable]
    public class MaterialProcessItemDTO
    {
        #region 构造函数

        public MaterialProcessItemDTO() { }

        internal MaterialProcessItemDTO(MaterialProcessItem item)
        {
            this.ID = item.ID;
            this.RawMaterialId = item.RawMaterialID;
            this.SemiMaterialId = item.SemiMaterialID;
            this.ActualPickCount = item.ActualPickCount;
            this.ActualStorageCount = item.ActualStorageCount;
            this.ExpectedPickCount = item.ExpectedPickCount;
            this.ExpectedStorageCount = item.ExpectedStorageCount;

            this.RawMaterial = MaterialDTOCache.Get(item.RawMaterialID);
            this.SemiMaterial = MaterialDTOCache.Get(item.SemiMaterialID);

        }

        #endregion

        #region 基本属性

        public string ID { get; set; }

        public string RawMaterialId { get; set; }

        public MaterialDTO RawMaterial { get; protected set; }

        public string SemiMaterialId { get; set; }

        public MaterialDTO SemiMaterial { get; protected set; }

        /// <summary>
        /// 期望领料数
        /// </summary>
        public decimal ExpectedPickCount { get; set; }

        /// <summary>
        /// 实际领料工数
        /// </summary>
        public decimal? ActualPickCount { get; set; }

        /// <summary>
        /// 期望入库数
        /// </summary>
        public decimal ExpectedStorageCount { get; set; }

        /// <summary>
        /// 实际入库数
        /// </summary>
        public decimal? ActualStorageCount { get; set; }

        #endregion

        #region 方法


        internal MaterialProcessItem ToMaterialProcessItem()
        {
            MaterialProcessItem item = new MaterialProcessItem();
            CopyToMaterialProcessItem(item);
            return item;

        }

        internal void CopyToMaterialProcessItem(MaterialProcessItem item)
        {
            item.RawMaterialID = this.RawMaterialId;
            item.SemiMaterialID = this.SemiMaterialId;
            item.ActualPickCount = this.ActualPickCount;
            item.ActualStorageCount = this.ActualStorageCount;
            item.ExpectedPickCount = this.ExpectedPickCount;
            item.ExpectedStorageCount = this.ExpectedStorageCount;
        }

        #endregion
    }
}
